<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>照片录入</title>
    <link href="../../../layui/css/layui.css" rel="stylesheet">
    <link href="../../../static/css/style.css" rel="stylesheet">
    <script src="../../../static/js/jquery.min.js"></script>
    <script src="../../../static/js/jquery.cookie.js"></script>
    <script src="../../../layui/layui.js"></script>
    <script src="../../../static/js/base.js"></script>
    <script src="../../../static/js/ax.js"></script>
    <script src="../../../static/js/avalon.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="../../../static/js/html5.js"></script>
    <script src="../../../static/js/respond.js"></script>
    <![endif]-->

</head>
<body class="bg_w" style="text-align: center">

<div>
    <div class="layui-card-body">

        <!--这个div 一定不能放在 form里面 -->
        <div style="text-align:center; padding-top: 20px;" >
            <object classid="clsid:454C18E2-8B7D-43C6-8C17-B1825B49D7DE" id="captrue"  width="80%" height="300" style="border: 1px solid #cdcdcd;"></object>
        </div>
        <image src="" id="base"/>

        <form class="layui-form layui-form-pane" action="" lay-filter="component-form-element">
            <div class="layui-form-item layui-col-space10">
                <div class="layui-input-block">
                    <button onclick="btnClose" class="layui-btn layui-btn-primary btn-left">关闭</button>
                    <button class="layui-btn add_btn btn-left" lay-submit lay-filter="component-form-element">提交</button>
                    <a class="layui-btn add_btn btn-left" onclick="zhuaPa()">抓拍</a>
                    <a class="layui-btn add_btn btn-left" onclick="PINSet()">PIN设置</a>
                    <a class="layui-btn add_btn btn-left" onclick="canSu()">参数设置</a>


                </div>
            </div>
        </form>
    </div>
</div>


</body>

<script  language="javascript" type ="text/javascript">
    //0 就是只有一面   1就是有正反面 需要拍两次  2 拍照
    var zf = getQueryString("zf");
    var fileTypes=getQueryString("fileTypes"); //上传时候需要
    console.log('正反面'+zf+'类型'+fileTypes)
    $(document).ready(function(){
        Init();
    });
    function Init() {
        //关闭
        var str=captrue.bStopPlay();
        if(zf==2)
        {
            //前置摄像头
            var str = captrue.bStartPlay2(0);
            captrue.vSetDelHBFlag(false); /**false：不去除黑边*/

        }
        if(zf==1)
        {
            var str = captrue.bStartPlay();
            captrue.bSetMode(4);
            captrue.vSetRotate(0);
            captrue.bSetIamgeXYZoom(1);
            captrue.vSetImageQuality(100);
            captrue.vSetDelHBFlag(true);
        }
        if(zf==0)
        {
            //就是只有一面
            var str = captrue.bStartPlay();
            captrue.bSetMode(0);
            captrue.vSetRotate(270);
            captrue.bSetIamgeXYZoom(0.5);
            captrue.vSetImageQuality(70);
            captrue.vSetDelHBFlag(true);
        }


    }
    //关闭
    function btnClose()
    {
        var str=captrue.bStopPlay();
    }

    //抓拍
    function zhuaPa()
    {

        uploadImg_C();

    }
    //参数
    function canSu()
    {
        var str=captrue.displayVideoPara();
    }
    //pin设置
    function PINSet()
    {
        var str=captrue.displayVideoPara();
    }

    //上传文件
    function uploadImg_C()
    {
        try {

            var zpPath = 'C:\\' + fileTypes + ".jpg";
            //这个地址需要给后台处理 ajax调用 返回 前段 一个base64的值
            alert(zpPath);

        } catch (err) {
            alert(err.message);
        }
    }


    /////////////////////////////////////////////////////////////////////////////////////////
    var datas=getQueryString("class");

    var vm = avalon.define({
        $id:'test',
        zwimg1:'',
        zwimg2:'',
        zwimg3:'',
        //给父级赋值
        setvalue:function () {
            if(fileTypes=='zjz'){
                parent.document.getElementById("zjzoId").value = '0';
                console.log(parent.document.getElementById("zjzoId").value)
            }
            if(fileTypes=='yjsz'){
                parent.document.getElementById("cxjsId").value = '0'
            }
            if(fileTypes=='sfz'){
                parent.document.getElementById("idzId").value = '0'
            }
            if(fileTypes=='tjbtp'){
                parent.document.getElementById("tjbtpId").value = '0'
            }
            if(fileTypes=='xcz'){
                parent.document.getElementById("scenePhotosId").value = '0'
            }
            if(fileTypes=='jzz'){
                parent.document.getElementById("zzpermitId").value = '0'
            }


        }
    });
    vm.$watch('studentdata', function () {

    });

    var table;
    var form;

    layui.use(['table','form','laydate','layer','upload'], function() {
        table = layui.table;
        form = layui.form;
        var laydate = layui.laydate,
            layer=layui.layer,
            $ = layui.jquery,
            upload = layui.upload;


        //监听提交
     form.on('submit(component-form-element)', function(data){
         vm.setvalue();
         // parent.layer.close(parent.layer.getFrameIndex(window.name));

         // var ss=[];
         // for(var s in vm.stuid){
         //    var list={"studentId":vm.stuid[s].studentId,"examSubject":datas,"examTime":data.field.examTime,"examAddress":data.field.examAddress}
         //     ss.push(list)
         // }
         //
         // console.log(JSON.stringify(ss))
         // ax.post({
         //     url: schoolWebUrl + "/api/studentExam/studentYueKaoExamAdd",
         //     data: JSON.stringify(ss),
         //     success: function (data) {
         //         // layer.msg(data.message);
         //         if (data.code == 0) {
         //             //刷新父页面
         //             layer.msg('约考成功')
         //             //刷新父页面
         //             topFrame.location.reload();
         //             setTimeout(function () {
         //                 parent.layer.close(parent.layer.getFrameIndex(window.name));
         //             },300)
         //         } else {
         //             layer.msg('约考失败')
         //         }
         //     }
         // });
         return false;

     });

        //关闭弹窗
        $('#btnClose').on("click", function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        });
    });


</script>
</html>